package templateExcel;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ValueQuote extends TemplateQuote {

    private String quoteName;

    @Override
    public String getQuoteName() {
        if (quoteName == null) {
            quoteName = "__value_" + IdFactory.id();
        }
        return quoteName;
    }

    @Override
    public void bind(Map<String, Object> values) {

    }

    @Override
    public Object getValue(Map<String, Object> values, int i, int j) {
        //始终获取名称对应的结果
        return values.get(name);
    }

    @Override
    public int maxI(Map<String, Object> values) {
        return 0;
    }

    @Override
    public int maxJ(Map<String, Object> values) {
        return 0;
    }


    public static void main(String[] args) {

        String s = "concat(abc,array[0,$len1,v][0,20,handleArray],array1[0,100,v],_____STRING_NAME_0)";


        //(\[([^\[\]])])?
        Pattern array_expression_pattern = Pattern.compile("(\\[([^\\[\\]]+)])(\\[([^\\[\\]]+)])?");

        Matcher matcher = array_expression_pattern.matcher(s);

        while (matcher.find()) {
            System.out.println(matcher.group(2));
            System.out.println(matcher.group(4));
        }

    }

}
